package com.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB {
	public static Connection getConnection(String ip, String dbName,
			String user, String pwd) {
		Connection conn = null;
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
//			 String URL = "jdbc:sqlserver://" + server + ":1433" + ";DatabaseName="
//		                + dbname;
			
			conn = DriverManager.getConnection("jdbc:sqlserver://" + ip + ":1433;DatabaseName="+dbName
					, user, pwd);

		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block

			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;

	}

	public static Connection getConnection() {
		
		Connection connection202 = getConnection("202.115.91.220", "pro", "sa",
				"sa123");

		return connection202;
	}
	
	public static void main(String[] args) {
		System.out.println(getConnection());
		
	}

}
